﻿using Little.Soldier.SWIFT;
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Reflection;

namespace Little.Soldier
{
    internal sealed class IUnparsedTextList : ExpandableObjectConverter
  {
    public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
    {
      if (destinationType == typeof (InstanceDescriptor))
        return true;
      else
        return base.CanConvertTo(context, destinationType);
    }

    public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
    {
      if (destinationType != typeof (InstanceDescriptor) || value.GetType().FullName != "LittleSoldier.UnparsedTextList")
        return base.ConvertTo(context, culture, value, destinationType);
      else
        return (object) new InstanceDescriptor((MemberInfo) typeof (UnparsedTextList).GetConstructor(Type.EmptyTypes), (ICollection) null, false);
    }
  }
}
